Skip to content

Add window expression part 1 - logical and physical planning, structure, to/from proto, and explain, for empty over clause only#334

Merged
alamb merged 21 commits intoapache:masterfrom
jimexist:add-window-expr
May 21, 2021
Merged

Add window expression part 1 - logical and physical planning, structure, to/from proto, and explain, for empty over clause only#334
alamb merged 21 commits intoapache:masterfrom
jimexist:add-window-expr

Conversation

@jimexist
Copy link
Member

@jimexist jimexist commented May 13, 2021

Which issue does this PR close?

We'd like to support window function in three or more steps:

  1. Support window functions with basic logical planning and physical planning #359 basic structure
  2. Support window functions with empty OVER clause #298 empty over clause
  3. Support window functions with PARTITION BY clause #299 with partition clause
  4. Support window functions with order by #360 with order by
  5. Support window functions with window frame #361 with window frame

Closes #359.

This is partly re #298.

Work to be done next: finish #298 and #299

Rationale for this change

this is a very stretch version of adding window function constructs to the planner, proto, etc.

What changes are included in this PR?

  • logical expression for window expression
  • physical expression for window expression
  • basic exec plan structure
  • basic from/to proto parsing
  • support explain parsing now
> explain select c1, sum(c3) over () from test;
+--------------+------------------------------------------------------------------+
| plan_type    | plan                                                             |
+--------------+------------------------------------------------------------------+
| logical_plan | Projection: #c1, #SUM(c3)                                        |
|              |   WindowAggr: windowExpr=[[SUM(#c3)]] partitionBy=[], orderBy=[] |
|              |     TableScan: test projection=None                              |
+--------------+------------------------------------------------------------------+
1 row in set. Query took 0 seconds.
> explain select c1, c3, sum(c3 + 2) over () from test;
+--------------+--------------------------------------------------------------------------------+
| plan_type    | plan                                                                           |
+--------------+--------------------------------------------------------------------------------+
| logical_plan | Projection: #c1, #c3, #SUM(c3 Plus Int64(2))                                   |
|              |   WindowAggr: windowExpr=[[SUM(#c3 Plus Int64(2))]] partitionBy=[], orderBy=[] |
|              |     TableScan: test projection=None                                            |
+--------------+--------------------------------------------------------------------------------+
1 row in set. Query took 0 seconds.
> explain select c1, c3, sum(c3) over (), max(c3) over (), avg(c3) over () from test;
+--------------+--------------------------------------------------------------------------------------+
| plan_type    | plan                                                                                 |
+--------------+--------------------------------------------------------------------------------------+
| logical_plan | Projection: #c1, #c3, #SUM(c3), #MAX(c3), #AVG(c3)                                   |
|              |   WindowAggr: windowExpr=[[SUM(#c3), MAX(#c3), AVG(#c3)]] partitionBy=[], orderBy=[] |
|              |     TableScan: test projection=None                                                  |
+--------------+--------------------------------------------------------------------------------------+
1 row in set. Query took 0 seconds.

Are there any user-facing changes?

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support window functions with basic logical planning and physical planning

7 participants